package com.mayavi.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.mayavi.bo.MovieBo;
import com.mayavi.dao.IMovieDao;

public class MovieDaoImpl implements IMovieDao{
	private HibernateTemplate hibernateTemplate;
	
	public void setSessionFactory(SessionFactory sessionFactory){
		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
	}
	
	@Override
	public List<MovieBo> getAllMovies() {
		return hibernateTemplate.find("from MovieBo");
	}

	@Override
	public MovieBo getMovieById(Integer id) {
		return (MovieBo)hibernateTemplate.get(MovieBo.class, id);
	}

	@Override
	public void saveMovie(MovieBo movieBo) {
		hibernateTemplate.saveOrUpdate(movieBo);
	}

}
